obj-m := gtp.o

KERNELDIR := /lib/modules/`uname -r`/build/
CROSS_COMPILE :=
MODULEDIR := /lib/modules/`uname -r`/misc/
#ARCH := i386
#ARCH := x86_64
#ARCH := mips
#ARCH := arm

PWD  := $(shell pwd)
ifeq ($(D),1)
EXTRA_CFLAGS := -DGTPDEBUG
endif

default:
ifneq ($(ARCH),)
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(PWD) modules
else
	$(MAKE) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(PWD) modules
endif

clean:
ifneq ($(ARCH),)
	$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(PWD) clean
else
	$(MAKE) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(PWD) clean
endif

install: default
	mkdir -p $(MODULEDIR)
	cp gtp.ko $(MODULEDIR)
	depmod -a

uninstall:
	rm -rf $(MODULEDIR)gtp.ko
	depmod -a
